#include "PlayerManager.h"
#include "BasePlayer.h"
#include <assert.h>

void PlayerManager::RegisterEntity(BasePlayer *player)
{
	m_playerMap.insert(std::pair<int,BasePlayer*>(player->ID(),player));
}

void PlayerManager::RemoveEntity(BasePlayer* player)
{
	m_playerMap.erase(m_playerMap.find(player->ID()));
}

BasePlayer* const PlayerManager::GetEntityByID(int id)const
{
	PlayerMap::const_iterator ent = m_playerMap.find(id);

	//if not find, ent == m_entMap.End()
	assert( ent!=m_playerMap.end() && "PlayerManager:GetElementByID : ID not found." );

	return ent->second;
}

